package lucene.server.web;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.env.Environment;
import org.springframework.scheduling.annotation.EnableScheduling;

import java.net.InetAddress;
import java.net.UnknownHostException;


@Configuration
@EnableScheduling
@SpringBootApplication(scanBasePackages="lucene.server.*")
public class SearchApplication {

    public static void main(String[] args) throws UnknownHostException {


        ConfigurableApplicationContext application = SpringApplication.run(SearchApplication.class, args);

        Environment env = application.getEnvironment();
        String ip = InetAddress.getLocalHost().getHostAddress();
        String port = env.getProperty("server.port");
        String path = env.getProperty("server.servlet.context-path")==null?"":env.getProperty("server.servlet.context-path");
        System.out.println(String.format(
                "\n---------------------------------------------------------\n" +
                "\tApplication is running! Access address:\n" +
                "\n\tManage:\thttp://localhost:%s/manager/index.html" +
                "\n---------------------------------------------------------\n", port, path) );

    }

}
